#pragma once

#include <QByteArray>
#include <QList>
#include <QSet>
#include <QRegExp>
#include <memory>

typedef unsigned char Char; 

typedef QSet<Char> CharCodeSet;

class CharType
{
public:
    enum EType
    {
        DATA,
        CONTROL,
        NOTYPE,
        typeCount
    };

    enum EMatch
    {
        NORMAL,
        ANY,
        NONE
    };

public:
    CharType(const QString& character);
    
    const CharCodeSet& Possible();
    const CharCodeSet& Impossible();

    void SetValue(const QByteArray& data);
    const QByteArray& Value();

    EType Type();   
    EMatch Match();

    bool  IsRegExp();
    QRegExp& RegExp();

private:
    void CreateCharacterList(const QString& character);
    void CreateList(const QString& list, CharCodeSet& set);
    void CreateRegExp(const QString& character);

private:
    QByteArray  _value;
    EType       _type;
    EMatch      _match;

private:
    QRegExp     _regExp;
    bool        _isRegExp;

private:
    CharCodeSet _possible;
    CharCodeSet _impossible;
};

typedef std::tr1::shared_ptr<CharType> CharTypePtr;
typedef QList<CharTypePtr> CharTypeList;